<?php
include "../config.php";
include "../util/functions.php";
session_start();

checkUserSession();

$mylink = mySqlOpen($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $member = array(
        "id"        => $_POST['id'],
        "name"      => $_POST['name'],
        "address"   => $_POST['address'],
        "inn"       => $_POST['inn'],
        "ogrn"      => $_POST['ogrn'],
        "cert_num"  => $_POST['cert_num'],
        "ext_info"  => $_POST['ext_info'],
    );
    updateMember($member);
} else {
    $memberId = $_REQUEST['memberId'];
    $member = getMember($memberId);
}

mySqlClose($mylink);

?>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <title>Реестр членов(<?php print count ($members); ?>)</title>
    <link href="../css/sro.css" rel="stylesheet" type="text/css">
    <script src="../js/Event.js" language="javascript"></script>
    <script src="../js/modificatMenu.js" language="javascript"></script>
    <script src="../js/resize.js" language="javascript"></script>

    <link rel="stylesheet" type="text/css" href="../css/jquery.css" media="screen">
    <script type="text/javascript" src="../js/jquery-1.js"></script>
    <script type="text/javascript" src="../js/jquery.js"></script>
    <script type="text/javascript" src="../js/jquery_002.js"></script>

    <script type="text/javascript">
        $(document).ready(function() {

        });
    </script>

</head>
<body>
<div id="container">
<?php
$SELECTED_MENU="menu-1";
include "banner.php"
?>
    <div class="workzone">
        <div style="height: 197px; min-height: 197px;" id="text">

            <h2 class="blueheading24">Редактирование члена:</h2>

            <form action="member_edit.php" method="post">
                <input type="hidden" name="id" value="<?php print $member['id'] ?>">

                <div class="edit_member_div">
                    <table>
                        <tr>
                            <th>наименование</th>
                            <td>
                                <input name="name" value="<?php print htmlspecialchars ($member['name']); ?>">
                            </td>
                        </tr>
                        <tr>
                            <th>адрес</th>
                            <td>
                                <input name="address" value="<?php print htmlspecialchars ($member['address']); ?>">
                            </td>
                        </tr>
                        <tr>
                            <th>ИНН</th>
                            <td>
                                <input name="inn" value="<?php print htmlspecialchars ($member['inn']); ?>">
                            </td>
                        </tr>
                        <tr>
                            <th>ОГРН</th>
                            <td>
                                <input name="ogrn" value="<?php print htmlspecialchars ($member['ogrn']); ?>">
                            </td>
                        </tr>
                        <tr>
                            <th>Номер свидетельства</th>
                            <td>
                                <input name="cert_num" value="<?php print htmlspecialchars ($member['cert_num']); ?>">
                            </td>
                        </tr>
                        <tr>
                            <th>Ext info</th>
                            <td>
                                <textarea rows="20" cols="75"
                                          name="ext_info"><?php print $member['ext_info'] ?></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <input class="save_btn" type="submit" value="Сохранить">
                            </td>
                        </tr>
                    </table>
                </div>

            </form>


        </div>


    <div class="clear"></div>
    <div class="footer">
        <!--TODO: add footer-->
    </div>

    <div style="display:none;">
        <form id="actionForm" action="members.php" method="post">
            <input type="hidden" name="action">
            <input type="hidden" name="memberId">
        </form>
        <form id="actionFormEdit" action="member_edit.php">
            <input type="hidden" name="memberId">
        </form>
    </div>

</div>


</body>
</html>


